package com.yzion.baselib.dialog

import android.content.Context
import android.view.Gravity
import android.widget.FrameLayout
import com.yzion.baselib.R

/**
 * ZJJ
 * 从底部弹出来的弹窗基类
 **/
abstract class BaseBottomDialog(context: Context) :
    BaseDialog(context, R.style.CustomDialog) {

    override fun onStart() {
        super.onStart()
        initWindow()
    }

    private fun initWindow() {
        window?.let {
            // 铺满横屏的代码，Dialog默认会有左右padding
            it.decorView.setPadding(0, 0, 0, 0)
            val lp = it.attributes
            it.setGravity(Gravity.BOTTOM)
            lp.width = FrameLayout.LayoutParams.MATCH_PARENT
            lp.height = FrameLayout.LayoutParams.WRAP_CONTENT
            it.setWindowAnimations(R.style.DialogBottomAnimation)
            it.attributes = lp
        }
    }
}